package com.cole.gx095.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Objects;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "salebill")
public class Salebill {
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Id
    @Column(name = "id")
    private int id;
    @Basic
    @Column(name = "BillNum")
    private String billNum;
    @Basic
    @Column(name = "ContractId")
    private Integer contractId;
    @Basic
    @Column(name = "ContractNum")
    private String contractNum;
    @Basic
    @Column(name = "BillDate")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date billDate;
    @Basic
    @Column(name = "BillType")
    private String billType;
    /**
     * 发票金额
     */
    @Basic
    @Column(name = "BillAccount")
    private Double billAccount;
    /**
     * 0待完成 1完成
     */
    @Basic
    @Column(name = "Status")
    private Integer status;
    /**
     * 0成本占用 1进入补票界面
     */
    @Basic
    @Column(name = "BillStatus")
    private Integer billstatus;
    @Basic
    @CreatedDate
    @Column(name = "CreateDate")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Timestamp createDate;
    @Basic
    @Column(name = "AttachCount")
    private Integer attachCount;
    @Basic
    @Column(name = "UpdateCount")
    private Integer updateCount;
    @Basic
    @Column(name = "CreateAdminTrueName")
    private String createAdminTrueName;
    /**
     * 关联金额
     */
    @Basic
    @Column(name = "CorrelationAmount")
    private Double correlationAmount;
    @Basic
    @Column(name = "CorrelationRate")
    private Double correlationRate;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getBillNum() {
        return billNum;
    }

    public void setBillNum(String billNum) {
        this.billNum = billNum;
    }

    public String getContractNum() {
        return contractNum;
    }

    public void setContractNum(String contractNum) {
        this.contractNum = contractNum;
    }

    public String getBillType() {
        return billType;
    }

    public void setBillType(String billType) {
        this.billType = billType;
    }

    public Timestamp getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Timestamp createDate) {
        this.createDate = createDate;
    }

    public Integer getAttachCount() {
        return attachCount;
    }

    public void setAttachCount(Integer attachCount) {
        this.attachCount = attachCount;
    }

    public Integer getUpdateCount() {
        return updateCount;
    }

    public void setUpdateCount(Integer updateCount) {
        this.updateCount = updateCount;
    }

    public String getCreateAdminTrueName() {
        return createAdminTrueName;
    }

    public void setCreateAdminTrueName(String createAdminTrueName) {
        this.createAdminTrueName = createAdminTrueName;
    }

    public Double getCorrelationAmount() {
        return correlationAmount;
    }

    public void setCorrelationAmount(Double correlationAmount) {
        this.correlationAmount = correlationAmount;
    }

    public Double getCorrelationRate() {
        return correlationRate;
    }

    public void setCorrelationRate(Double correlationRate) {
        this.correlationRate = correlationRate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Salebill salebill = (Salebill) o;
        return id == salebill.id && Objects.equals(billNum, salebill.billNum) && Objects.equals(contractNum, salebill.contractNum) && Objects.equals(billType, salebill.billType) && Objects.equals(createDate, salebill.createDate) && Objects.equals(attachCount, salebill.attachCount) && Objects.equals(updateCount, salebill.updateCount) && Objects.equals(createAdminTrueName, salebill.createAdminTrueName) && Objects.equals(correlationAmount, salebill.correlationAmount) && Objects.equals(correlationRate, salebill.correlationRate);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, billNum, contractNum, billType, createDate, attachCount, updateCount, createAdminTrueName, correlationAmount, correlationRate);
    }
}
